<template>
  <DataTablePage
    mainColumn="name"
    longColumn="remark"
    resource="/dxbase/rbac/role"
    title="角色管理"
    label="角色"
    labelName="name"
    :toolbar="toolbar"
    :operation="operation"
    :operationWidth="100"
    :tableFullList="tableFullList"
    :tableInitList="tableInitList"
    :filterFullList="filterFullList"
    :filterInitList="filterInitList"
    :createList="createList"
    :updateList="updateList"
    :createFormValues="createFormValues"
    :columns="columns"
  />
</template>

<script>
import DataTablePage from '@/containers/DataTablePage'
import { toolbarCreate } from '@/containers/DataTablePage/toolbar'
import { operationUpdate, operationDelete } from '@/containers/DataTablePage/operation'
import { checkActions } from '@/utils/auth'
import config from '../config/role'

export default {
  name: 'role',
  components: {
    DataTablePage
  },
  data () {
    const hasUpdate = checkActions('/system/#/role/update')
    const hasDelete = checkActions('/system/#/role/delete')
    return {
      ...config,
      toolbar: [{
        ...toolbarCreate,
        isShow () {
          return checkActions('/system/#/role/create')
        }
      }],
      operation: [{
        ...operationUpdate,
        isShow () {
          return hasUpdate
        }
      }, {
        ...operationDelete,
        isShow () {
          return hasDelete
        }
      }],
      tableInitList: ['id', 'name', 'enabled', 'remark'],
      tableFullList: ['id', 'name', 'enabled', 'remark'],
      createList: ['name', 'menuIds', 'enabled', 'remark'],
      updateList: ['name', 'menuIds', 'enabled', 'remark'],
      filterInitList: ['name', 'enabled'],
      filterFullList: ['name', 'enabled', 'remark'],
      createFormValues: {
        name: '',
        menuIds: [],
        enabled: true,
        remark: ''
      }
    }
  }
}
</script>
